package com.wxw.BaseLibrary.element;

/**
 * Created by david on 2015-12-21.
 */
public class SearchElement {
    private String text = "";
    private String value = "";
    private String key = "";
    private String tableName = "";
    private int vType = 0;
    private String compare = "";

    public SearchElement(String text, String value, String key, String tableName, String compare, int t) {
        this.text = text;
        this.value = value;
        this.key = key;
        this.tableName = tableName;
        this.vType = t;
        this.compare = compare;
    }

    public SearchElement(String text, String value, String key, String tableName, String compare) {
        this(text,value,key,tableName,compare,0);
    }

    public SearchElement(String text, String value, String key, String tableName, int t) {
        this(text,value,key, tableName,"=",t);
    }


    public SearchElement(String text, String value, String key, String tableName) {
        this(text, value, key, tableName, "=", 0);
    }

    public String getSearchString(){
        if ("".equals(value)) {
            return "";
        }
        return key + " "+ compare+" " + (vType==0?"'":"")+value+(vType==0?"'":"");
    }

    @Override
    public String toString() {
        return text;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public int getVType() {
        return vType;
    }

    public void setVType(int vType) {
        this.vType = vType;
    }

    public String getCompare() {
        return compare;
    }

    public void setCompare(String compare) {
        this.compare = compare;
    }
}
